<template>
	<view>
		<drag-button :isDock="true" :existTabBar="true" name="我要当老师" @btnClick="btnClick" />
		<u-list @scrolltolower="scrolltolower" v-if="show">
			<u-list-item v-for="(item, index) in noticelist" :key="index">


				<view class="cu-card dynamic isCard mtop" @click="handleClick(item)">
					<view class="cu-item shadow">
						<view class="PhotographerBoxL">
							<view class="cu-avatar round  ">

								<u-avatar size="50" :src="url_prefix+item.remark1"></u-avatar>

							</view>

							<view class="text-bold margin-top-sm">{{item.teacherName}}({{item.teacherGender}})</view>
							<view class='cu-tag2 margin-top-xs bg-blue radius'>{{item.teacherSchool || "暂无"}}</view>
							<view class="text-xs margin-top-sm   bg-blue light radius">专业：{{item.teacherSpeciality}}
							</view>
						</view>
						<view class="PhotographerBoxR">
							<view class="text   text-black light radius mtop">教学方式:{{item.teachingMethod}}</view>
							<view class="text-sm text-grey margin-top-xs text mtop">{{item.teacherDescribe}}</view>

							<view class="PhotoPpl margin-top-xs flex justify-start">
								<view class=" text-black">科目：</view>
								<view class="cu-tag margin-right-xs bg-olive light radius">
									{{item.teachingParentingSubjects1}}

								</view>
								<view class="cu-tag bg-purple light radius" v-if="item.teachingParentingSubjects2">
									{{item.teachingParentingSubjects2}}
								</view>

								<view class="cu-tag bg-pink light radius" v-if="item.teachingParentingSubjects3">
									{{item.teachingParentingSubjects3}}
								</view>

							</view>
							<view class="PhotoPpl margin-top-xs flex justify-start">
								<view class=" text-black">地区：</view>
								<view class="cu-tag   bg-blue light radius">
									{{item.teachingArea1}}
								</view>
								<view class="cu-tag bg-mauve light radius" v-if="item.teachingArea2">
									{{item.teachingArea2}}
								</view>
								<view class="cu-tag bg-cyan light radius" v-if="item.teachingArea3">
									{{item.teachingArea3}}
								</view>

							</view>
						</view>
						<view class="padding-sm text-center fl text-bold text-blue goPhotographer">联系名师</view>
					</view>



				</view>
			</u-list-item>
		</u-list>

		<view class="page-box" v-else>
			<view>
				<view class="centre" v-if="showcentre">
					<image src="https://cdn.zhoukaiwen.com/noData1.png" mode="widthFix"></image>
					<view class="explain">
						暂无数据
						<view class="tips">可以去看看有其他</view>
					</view>
					<!-- <view class="btn">随便逛逛</view> -->
				</view>
			</view>
		</view>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				// adlist:this.myad()[0],
				noticelist: [],
				new : true,
				show: false,
				showcentre: false,
				//默认模式是1，首页跳来是2
				type: "1",
				editFormFields: {
					pageNum: 1,
					pageSize: 10,
					auditStatus: '已审核',
					teachingParentingSubjects: ""
				},
				total: 0,
				url_prefix: this.http.ipAddress.replace(/\/$/, '')
			}
		},
		computed: {

		},
		onLoad(e) {

		},
		onShow() {
			var name = getApp().globalData.name; //赋值取得参数
			console.log(name);
			if (name != null) {
				this.type = "2";
				this.editFormFields.teachingParentingSubjects = name;
				// this.new = true;
			} else {
				// this.new = false;
			}
			
			if (this.new) {
				this.noticelist = []
				this.getNoticelist();
			}

		},
		onPullDownRefresh() {
			console.log('refresh');
			this.noticelist = [],
				// setTimeout(function () {
				// 	uni.stopPullDownRefresh();
				// }, 1000);
				this.editFormFields.pageNum = 1;
			this.getNoticelist();
		},
		methods: {
			btnClick() {


				let UserInfo = this.$store.getters.getUserInfo();
				if (UserInfo != null) {
					uni.navigateTo({
						url: '/pages/dz_teacher/dz_teacher_edit'

					});

				} else {
					uni.navigateTo({
						url: '/pages/login/login'

					});
				}
			},
			getMessage(teachingParentingSubjects, type) {
				if (type == 1) {

				} else {

				}


			},
			handleClick(item) {
				console.log(item.id)
				this.new=false;
				uni.navigateTo({
					url: '/pages/dz_teacher/dz_teacher_details?id=' + item.id

				});
				// uni.navigateTo({
				// 	url: '/pages/dz_teacher/details?id=' + item.id

				// });
			},
			scrolltolower() {

				// this.editFormFields.pageNum=;

				console.log(this.editFormFields.pageNum)
				if (this.total > this.editFormFields.pageNum * this.editFormFields.pageSize) {
					this.editFormFields.pageNum++;
					// console.log("请求数据")
					this.getNoticelist();
				}

			},

			getNoticelist() {
				let that = this
				this.http.get("wechat/teacher/list", this.editFormFields, "正在查询数据....").then(data => {
					uni.stopPullDownRefresh();
					this.showcentre = true;
					if (this.type = "2") {
						getApp().globalData.name = "";
					}

					if (data.code == 200) {


						var noticelist = this.noticelist;

						data.rows.forEach(function(item) {
							noticelist.push(item);
						})
						this.noticelist = noticelist;


						this.total = data.total;
						if (this.total == 0) {
							this.show = false;

						} else {
							this.show = true;

						}
					} else {
						this.show = false;

						this.$toast(data.msg)
					}
				})

			}
		}
	}
</script>

<style lang="less" scoped>
	.type_text {
		color: red
	}


	.label {
		// margin-bottom: 40rpx;
		font-size: 24rpx;
		color: #82848f;
	}

	.money {
		font-size: 38rpx;
		font-weight: 700
	}

	.Area {
		font-size: 38rpx;
		font-weight: 400;
		color: #55aaff;
	}

	.Describefather {
		height: 100%;
		// margin-right: 130rpx;
		margin-top: 30rpx;
		padding: 10rpx;
	}

	.Describe {

		font-size: 32rpx;
		// font-weight: 700;
		width: 100%;
		overflow-wrap: break-word;
		line-height: 52rpx;
		// margin: 16rpx 16rpx 26rpx 0;

	}

	.wrapper {
		background-color: #fff;
		padding: 30rpx 24rpx;
		margin-top: 30rpx;
	}

	.margin30 {
		margin-top: 10rpx;
		margin-left: 30rpx;
		margin-right: 30rpx;
	}

	.address {
		margin-top: 30rpx;
	}

	.top30 {
		margin-top: 30rpx;
	}

	.picBox {
		width: 750rpx;
		background-color: #1a1a1a;

		.picMain {
			width: 750rpx;
			height: 380rpx;
			padding: 10rpx 30rpx 30rpx 30rpx;

			.picL {
				width: 430rpx;
				height: 100%;

				image {
					border-radius: 8rpx;
					width: 100%;
					height: 100%;
				}
			}

			.picB {
				width: 250rpx;
				height: 100%;
				display: flex;
				flex-flow: column; //垂直排列
				justify-content: space-between; //两端对齐

				image {
					border-radius: 8rpx;
					width: 100%;
					height: 48%;
				}
			}
		}
	}

	.title-header {
		display: flex;
		height: 120rpx;
		font-size: 40rpx;
		align-items: center;
		justify-content: center;
		/* padding: 40rpx 0 0 0; */
		font-weight: bold;
		background-image: url(https://s1.ax1x.com/2020/09/16/wccswF.png);
		background-size: cover;
	}

	.title-text {
		background-image: -webkit-linear-gradient(0deg, #ff8a34, #FBBD12);
		-webkit-background-clip: text;
		-webkit-text-fill-color: transparent;
	}

	.cu-card>.cu-item {
		margin: 0 30rpx 30rpx 30rpx;
	}

	.PhotographerBoxL {
		width: 35%;
		text-align: center;
		padding: 25rpx;
		margin-top: 15rpx;
		float: left;
	}

	.PhotographerBoxR {
		width: 65%;
		padding: 25rpx;
		float: left;

		.PhotoPpl {
			width: 100%;

			image {
				border-radius: 8rpx;
				width: 128rpx;
				height: 128rpx;
			}
		}
	}

	.cu-tag2 {
		height: 40rpx !important;
		font-size: 22rpx;
		vertical-align: middle;
		position: relative;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		box-sizing: border-box;
		padding: 0rpx 16rpx;
		font-family: Helvetica Neue, Helvetica, sans-serif;
		white-space: nowrap;
	}

	.goPhotographer {
		width: 96%;
		margin: 0 2%;
		border-top: 1rpx #CCCCCC dashed;
	}

	.text {
		overflow: hidden;
		-webkit-line-clamp: 3;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.mtop {
		margin-top: 10rpx;
	}

	// 暂无数据
	.centre {
		text-align: center;
		margin: 200rpx auto;
		font-size: 32rpx;

		image {
			width: 300rpx;
			border-radius: 50%;
			margin: 0 auto;
		}

		.tips {
			font-size: 24rpx;
			color: #999999;
			margin-top: 20rpx;
		}

		.btn {
			margin: 80rpx auto;
			width: 200rpx;
			border-radius: 32rpx;
			line-height: 64rpx;
			color: #ffffff;
			font-size: 26rpx;
			background: linear-gradient(270deg, #1cbbb4 0%, #0081ff 100%);
		}
	}
</style>
